#include <iostream>
#include <cstring>

using namespace std;

void print(int* a,int len){
    for (int i = 0;i<len; i++) printf("%d ",a[i]);
    putchar('\n');
}

void add(){
    int maxlen=6;
    int sf,of,cf,zf=0,a[maxlen]={1,0,1},b[maxlen]={1,1,0},cin[maxlen+1]={0,0,0,0,0,0},res[maxlen]={0};
    
    puts("before add");
    print(a,maxlen);
    print(b,maxlen);
    print(cin,maxlen);
    print(res,maxlen);
    for (int i = 0; i < maxlen; i++)
    {
        res[i] = a[i] ^ b[i] ^ cin[i];
        if(res[i]&&zf==0)zf=1;
        cin[i+1] = (a[i] & b[i]) || (a[i]&cin[i]) || (b[i]&cin[i]);
    }
    puts("after add");
    print(a,maxlen);
    print(b,maxlen);
    print(cin,maxlen);
    print(res,maxlen);
    of = a[maxlen]==b[maxlen]&&a[maxlen]^res[maxlen];
    sf = res[maxlen];
    cf = cin[0]^cin[maxlen+1];
}

int mulres[8][8];
void mul(){
    int maxlen=6,i,j;
    int a[maxlen] = {0,1,1,1,1,1}, b[maxlen]={1,0,1,1,1,1},res[maxlen];
    puts("before mul");
    print(a,maxlen);
    print(b,maxlen);
    for ( i = 0; i < maxlen; i++) print(mulres[i],maxlen);
    
    for (i = 0; i < maxlen; i++)
    {
        for (j = 0; j < maxlen; j++)
        {
            if(i+j<maxlen)mulres[i][j+i] = a[i]*b[j];
        }
        
    }
    puts("after mul");
    print(a,maxlen);
    print(b,maxlen);
    for ( i = 0; i < maxlen; i++) print(mulres[i],maxlen);

}

int main(){
    add();
    mul();
}